	IDENTIFICATION DIVISION.
	PROGRAM-ID. OVERDUE.
	ENVIRONMENT DIVISION.
	INPUT-OUTPUT SECTION.
	FILE-CONTROL.
	    SELECT IN-FILE   ASSIGN TO DISK.
	    SELECT WORK-FILE ASSIGN TO DISK.
	    SELECT OUT-FILE ASSIGN TO DISK.
	DATA DIVISION.
	FILE SECTION.
	FD IN-FILE
	   LABEL RECORD STANDARD
	   VALUE OF FILE-ID IS "IN.DBF".
	01  IN-REC.
	    02 ACC-NO  PIC X(10).
	    02 AMOUNT  PIC 9(5).
	    02 SDATE.
	     03 SDAY   PIC 99.
	     03 FILLER PIC X.
	     03 SMONTH PIC 99.
	     03 FILLER PIC X.
	     03 SYEAR  PIC 9999.
	SD WORK-FILE.
	01  WORK-REC.
	   02 WACC-NO  PIC X(10).
	   02 WAMOUNT  PIC 9(5).
	   02 WSDATE.
	     03 WSDAY   PIC 99.
	     03 FILLER PIC X.
	     03 WSMONTH PIC 99.
	     03 FILLER PIC X.
	     03 WSYEAR  PIC 9999.
	FD OUT-FILE
	   LABEL RECORD STANDARD
	   VALUE OF FILE-ID IS "OUT.DBF".
	01  OUT-REC.
	    02 OACC-NO  PIC X(10).
	    02 OAMOUNT  PIC 9(5).
	    02 OSDATE.
	     03 OSDAY   PIC 99.
	     03 FILLER PIC X.
	     03 OSMONTH PIC 99.
	     03 FILLER PIC X.
	     03 OSYEAR  PIC 9999.
	
	WORKING-STORAGE SECTION.
	01  CDATE.
	     03 CDAY   PIC 99.
	     03 FILLER PIC X.
	     03 CMONTH PIC 99.
	     03 FILLER PIC X.
	     03 CYEAR  PIC 9999.
	77  RATE       PIC 9(2).
	77  CH         PIC X.
	77  C          PIC 9    VALUE IS 0.
	77  OVERDUE    PIC 99   VALUE IS 0.
	77  LATER      PIC 99   VALUE IS 0.
	77  TOTAMT     PIC 9(6) VALUE IS 0.
	77  LATERAMT   PIC 9(6) VALUE IS 0.
	77  DUEAMT     PIC 9(6) VALUE IS 0.
	77  DUEFLAG    PIC 9    VALUE IS 0.
	77  NUM        PIC 99   VALUE IS 0.
	77  DUMMY      PIC Z(6). 
	77  TAG     PIC X.
	PROCEDURE DIVISION.
	MAINPARA.
	    IF NOT C = 4 GO TO MENU.
	    STOP RUN.
	    
	NEW-FILE.    
	    DISPLAY "FILE CLEARED FOR INPUT ".
	    OPEN OUTPUT IN-FILE.
	    CLOSE IN-FILE.
	    GO TO MENU.
	
	WRITEPARA.
	    OPEN EXTEND IN-FILE.
	    DISPLAY (1, 1) ERASE. 
	    DISPLAY "------ DATA ENTRY ------".
	    GO TO NEWREC.
	
	NEWREC.    
	    DISPLAY " ".
	    DISPLAY (LIN, COL) "ACCOUNT NO  : ". 
	    ACCEPT ACC-NO.
	    DISPLAY (LIN, COL) "AMOUNT      : ". 
	    ACCEPT AMOUNT.
	    DISPLAY (LIN, COL) "DATE (DD/MM/YYYY) : ". 
	    ACCEPT SDATE.
	    WRITE IN-REC.
	    DISPLAY (LIN, COL) "CONTINUE <Y/N>?:".
	    ACCEPT CH.
	    IF CH = "Y" GO TO NEWREC.
	    CLOSE IN-FILE.
	    SORT WORK-FILE ON ASCENDING KEY WACC-NO USING IN-FILE
	    GIVING OUT-FILE.
	    GO TO MAINPARA.

	MENU.
	    DISPLAY (1, 1) ERASE.
	    DISPLAY "------ MENU ------".
	    DISPLAY " ".
	    DISPLAY " 1. CREATE NEW FILE".
	    DISPLAY " 2. ADD RECORDS".
	    DISPLAY " 3. REPORT".
	    DISPLAY " 4. EXIT ".
	    DISPLAY " ".  
	    DISPLAY (LIN, COL) "CHOICE : ".
	    ACCEPT C.
	    IF C = 1  GO TO NEW-FILE.
	    IF C = 2  GO TO WRITEPARA.
	    IF C = 3  GO TO OUTPARA.
	    GO TO MAINPARA.

	OUTPARA.
	    DISPLAY (1, 1) ERASE.
	    DISPLAY (LIN, COL) "CURRENT DATE (DD/MM/YYYY)?: ".
	    ACCEPT CDATE.
	    OPEN INPUT OUT-FILE.
	    GO TO OUTREC.
	OUTREC.
	    MOVE 0 TO OVERDUE, DUEAMT.
	    MOVE 0 TO LATER, LATERAMT.
	    DISPLAY (1, 1) ERASE.
	    DISPLAY "-------------------------------------------------".
	    DISPLAY "                     REPORT                      ".
	    DISPLAY "-------------------------------------------------".
	    DISPLAY " ACC-NO   AMOUNT  DUE-DATE  CURRENT-DATE  STATUS ".
	    DISPLAY "-------------------------------------------------". 
	    GO TO READREC.
	READREC.
	    READ OUT-FILE AT END GO TO WAITPARA.
	    MOVE 0 TO DUEFLAG.
	    IF CYEAR > OSYEAR MOVE 1 TO DUEFLAG.
	    IF ( CYEAR = OSYEAR ) AND ( CMONTH > OSMONTH )
						MOVE 1 TO DUEFLAG. 
	    IF ( CYEAR = OSYEAR ) AND ( CMONTH = OSMONTH )     
		 AND (CDAY > OSDAY ) MOVE 1 TO DUEFLAG.
	    IF ( DUEFLAG = 1) ADD 1 TO OVERDUE, ADD OAMOUNT TO DUEAMT,
			     MOVE "O" TO TAG
	    ELSE ADD 1 TO LATER, ADD OAMOUNT TO LATERAMT, 
			     MOVE "R" TO TAG.
	    DISPLAY " ", OACC-NO, OAMOUNT, " ", 
			  OSDATE, "  ", CDATE, "     ", TAG.
	    GO TO READREC.

	DISPARA.
	     
	    COMPUTE TOTAMT = DUEAMT + LATERAMT.
	    COMPUTE NUM = OVERDUE + LATER.
	    DISPLAY "   -OVERDUE ACCOUNTS-".
	    MOVE OVERDUE TO DUMMY.
	    DISPLAY "NUMBER OF ACCOUNTS: ", DUMMY.
	    MOVE DUEAMT  TO DUMMY.
	    DISPLAY "AMOUNT            : ", DUMMY.
	    DISPLAY " ".
	    DISPLAY "     -RECEIVABLES-".
	    MOVE LATER    TO DUMMY.
	    DISPLAY "NUMBER OF ACCOUNTS: ", DUMMY.
	    MOVE LATERAMT TO DUMMY.
	    DISPLAY "AMOUNT            : ", DUMMY.
	    DISPLAY " ".
	    DISPLAY "-TOTAL-".
	    MOVE NUM TO DUMMY.
	    DISPLAY "NUMBER OF ACCOUNTS: ", DUMMY.
	    MOVE TOTAMT TO DUMMY.
	    DISPLAY "AMOUNT            : ", DUMMY.
	    DISPLAY " ".
	    DISPLAY "-------------------------------------------------".
	    ACCEPT CH.
	    GO TO MAINPARA.
	WAITPARA.
	    DISPLAY "-------------------------------------------------".
	    CLOSE OUT-FILE.
	    GO TO DISPARA.


